﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Konves.Csv.Serialization
{
    [System.Diagnostics.DebuggerDisplay("{PropertyInfo.Name}: {FieldName}")]
    public class CsvFieldInfo : ICsvSerializationInfo
    {
        internal const string DefaultFormat = "";

        private CsvFieldInfo() { }
        public CsvFieldInfo(PropertyInfo propertyInfo, string fieldName, int fieldIndex, string format)
        {
            this.PropertyInfo = propertyInfo;
            this.FieldName = fieldName;
            this.FieldIndex = fieldIndex;
            this.UseIndex = fieldIndex >= 0;
            this.Format = format;
        }
        public CsvFieldInfo(PropertyInfo propertyInfo, string fieldName, int fieldIndex)
            : this(propertyInfo, fieldName, fieldIndex, DefaultFormat) { }

        public int FieldIndex { get; private set; }
        public string FieldName { get; private set; }
        public bool UseIndex { get; private set; }
        public string Format { get; private set; }

        public PropertyInfo PropertyInfo { get; private set; }

    }
}
